import cv2 as cv
import numpy as np

image = cv.imread("222.jpg")
b,g,r = cv.split(image)
imagebgr = cv.merge([b, g, r])

shape = image.shape

#和图像一样大小的0矩阵
zero_shape = np.zeros(image.shape[:2]).astype("uint8")

#创建一个图像大小的随机矩阵
image_1 = np.random.randint(0,256,size = shape,dtype=np.uint8)

#单独显示一个通道的颜色，空缺值的用0代替
image_b = cv.merge([b, zero_shape, zero_shape])
image_g = cv.merge([zero_shape, g, zero_shape])
image_r = cv.merge([zero_shape, zero_shape, r])

#将图像和随机矩阵融合
img_result = cv.add(image, image_1)

#打印图像参数
print("image.shape", image.shape)
print("image.size", image.size)
print("image.dtype", image.dtype)

#显示图像：
# cv.imshow("b", b)
# cv.imshow("g", g)
# cv.imshow("r", r)

# cv.imshow("image", image)
# cv.imshow("imagebgr", imagebgr)

cv.imshow("imageb", image_b)
cv.imshow("imageg", image_g)
cv.imshow("imager", image_r)

cv.imshow("img_result", img_result)

cv.waitKey()
cv.destroyAllWindows()


# #矩阵相减
# cv.subtract()
# #矩阵相加
# cv.multiply()
# #矩阵相乘
# cv.dot()
# #矩阵除法
# cv.divide()
# #矩阵逻辑运算
# cv.bitwise_or()
# cv.bitwise_and()
# cv.bitwise_not()
# cv.bitwise_xor()
